﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace SgAutoArchiveSp.Dialog
{
    public partial class Dialog_Tongji : DevExpress.XtraEditors.XtraForm
    {
        public Dialog_Tongji()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 统计列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_TongjiWork_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string sd = (sdate_control.EditValue==null? "" : Convert.ToDateTime(sdate_control.EditValue).ToString("yyyy-MM-dd"));
            string ed = (edate_control.EditValue==null? "": Convert.ToDateTime(edate_control.EditValue).ToString("yyyy-MM-dd"));

            ////MessageBox.Show(sd + " , " + ed);

            var list = SgAutoArchiveBrrDal.Linq.Tongji_Dal.Tongji_WorkCount(sd, ed);
            chart.Series[0].Points.Clear();
            if (list != null)
            {
                foreach (var n in list)
                {
                    double[] ds = new double[] { n.Count };
                    chart.Series[0].Points.Add(new DevExpress.XtraCharts.SeriesPoint() { Argument = n.Name, Values =ds });
                }
            }
        }

        /// <summary>
        /// 统计查档类型
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_TongjiType_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string sd = (sdate_control.EditValue == null ? "" : Convert.ToDateTime(sdate_control.EditValue).ToString("yyyy-MM-dd"));
            string ed = (edate_control.EditValue == null ? "" : Convert.ToDateTime(edate_control.EditValue).ToString("yyyy-MM-dd"));

            ////MessageBox.Show(sd + " , " + ed);

            var list = SgAutoArchiveBrrDal.Linq.Tongji_Dal.Tongji_WorkArchiveType(sd, ed);
            chart.Series[0].Points.Clear();
            if (list != null)
            {
                foreach (var n in list)
                {
                    double[] ds = new double[] { n.Count };
                    chart.Series[0].Points.Add(new DevExpress.XtraCharts.SeriesPoint() { Argument = n.Name, Values = ds });
                }
            }
        }
    }
}